<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of multiplePriorityAlgorith
 *
 * @author juwking
 */
require_once 'MailPackage.php';
class MultiplePriorityAlgorith {
    private $queArray;
    private $activePackage=0;
    function  __construct() {
        $this->queArray=array();
        $this->genMailPackages();
    }
    private function genMailPackages() {        
        for($i=0;$i<10;$i++)
        {
            array_push($this->queArray, array("package"=>new MailPackage(),"active"=>false));
        }
    }
    public function printStats()
    {
        $allMails=0;
        foreach ($this->queArray as $value) {
            $allMails+=$value["package"]->mailAmmount;
        }
        print_r("Wszystkie maile ".$allMails);
    }
    public function setNewPackage()
    {

        foreach ($this->queArray as $key => $value) {
            if($value["package"]->priority>$this->queArray[$this->activePackage]["package"]->priority)
                    $this->activePackage=$key;
        }
        print_r("Wybrano paczke z priorytetem ".
                $this->queArray[$this->activePackage]["package"]->priority.
                " ma ona numer ".
                $this->activePackage.
                " i posiada ".$this->queArray[$this->activePackage]["package"]->mailAmmount.
                " maili do wyslania");
        print_r("<br>");
    }
    public function sendMails()
    {
        
    }
}
?>
